NOTE
1.29 InnoDB Buffer Pool
1. What Is the Buffer Pool - A contiguous memory space requested from the operating system when MySQL starts 2. Why the Buffer Pool Is Needed - The speed gap between disk and CPU is too large, so memory is needed as a cache - When InnoDB accesses table and index data, it caches them here, greatly reducing disk I/O and improving efficiency 3. Buffer Pool Workflow
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is the Buffer Pool
- A contiguous memory space requested from the operating system when MySQL starts.
2. Why the Buffer Pool Is Needed
- The speed gap between disk and CPU is too large, so memory is needed as a cache.
- When InnoDB accesses table and index data, it caches them here, greatly reducing disk I/O and improving efficiency.
3. Buffer Pool Workflow
- When reading data, read from the Buffer Pool first. If it exists there, return it directly; otherwise read it from disk and then place it in the Buffer Pool.
- When writing, write to the Buffer Pool and periodically flush it to disk.
4. How the Buffer Pool Is Implemented
4.1. Paging
- Divide the Buffer Pool into cache pages with the same size as a page.
- A control block is allocated at the beginning of each cache page. It stores information such as the tablespace number the page belongs to, page number, the address of the cache page in the Buffer Pool, and linked-list node information.
4.2. free List
- Used to distinguish which cache pages in the Buffer Pool are free and which have already been used.
- Put the control block corresponding to every free cache page into a linked list as a node.

4.3. Hash Table
- Used to check whether a page is in the cache.
- Create a hash table using tablespace number + page number as the key and the cache page as the value.
4.4. LRU List
- When there is no free space in the free list, cold pages in the Buffer Pool can be evicted to load new data.
- The eviction algorithm uses LRU: linked list + Hash.
4.5. flush List
- Used to store modified dirty pages in the Buffer Pool.

5. Using the Buffer Pool
5.1. Configure the Size
[server]
# Unit: Byte
innodb_buffer_pool_size = 268435456
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub